cmake_minimum_required(VERSION 3.8)
cmake_policy(SET CMP0069 NEW)

include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if( supported )
    message(STATUS "IPO / LTO enabled for the syncspirit-daemon")
    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
    message(STATUS "IPO / LTO not supported: <${error}>")
endif()

if (NOT ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AVR" ))
  message(FATAL_ERROR "wrong system processor ${CMAKE_SYSTEM_PROCESSOR}, expected: AVR")
endif()

message(STATUS "will use stdlib++ from '${LIBSTDCPP_HOME}'")
add_library(arduino common.cpp)

target_include_directories(rotor_light PUBLIC "${LIBSTDCPP_HOME}/include")

target_include_directories(arduino PUBLIC "${LIBSTDCPP_HOME}/include")
target_link_libraries(arduino rotor_light)


add_executable(blink-led blink-led.cpp)
target_link_libraries(blink-led arduino)

add_executable(blink-led-uart blink-led-uart.cpp)
target_link_libraries(blink-led-uart arduino)

add_executable(ping-pong-poll ping-pong-poll.cpp)
target_link_libraries(ping-pong-poll arduino)

add_executable(ping-pong-await ping-pong-await.cpp)
target_link_libraries(ping-pong-await arduino)

